import settings
#from django import http
#from django.core.mail import mail_managers
import md5
import re
import models

class RequestMiddleware(object):
    """
    "Common" middleware for taking care of some basic operations:

        - Forbids access to User-Agents in settings.DISALLOWED_USER_AGENTS

        - URL rewriting: Based on the APPEND_SLASH and PREPEND_WWW settings,
          this middleware appends missing slashes and/or prepends missing "www."s.

        - ETags: If the USE_ETAGS setting is set, ETags will be calculated from
          the entire page content and Not Modified responses will be returned
          appropriately.
    """


    def process_response(self, request, response):
        "Check for a flat page (for 404s) and calculate the Etag, if needed."
        models.ResquestCounter(ip = request.remote_addr, userAgent = request.user_agent, referer = request.referrer,url =request.url).put()

        return response